package top.retain;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author ivorfan
 * @date 2021/8/2 10:54
 */
public class AQSTest {

    public static void main(String[] args) {
        ReentrantLock reentrantLock = new ReentrantLock();
        reentrantLock.lock();
        System.out.println(reentrantLock.getHoldCount());
        for (int i = 0; i < 3;i++) {
            new Thread(reentrantLock::lock).start();
        }
        System.out.println(reentrantLock.hasQueuedThreads());
        System.out.println(reentrantLock.getQueueLength());
        System.out.println(reentrantLock.isHeldByCurrentThread());
        reentrantLock.lock();
        reentrantLock.unlock();
        reentrantLock.unlock();
        System.out.println(reentrantLock.isHeldByCurrentThread());
        System.out.println(reentrantLock.getQueueLength());
    }

}
